package com.michaelliu.study.viewpager2

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.google.android.material.tabs.TabLayoutMediator
import com.michaelliu.study.viewpager2.databinding.ActivityTabBinding

class TabActivity : AppCompatActivity() {

    private lateinit var mBinding: ActivityTabBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mBinding = ActivityTabBinding.inflate(layoutInflater)
        setContentView(mBinding.root)

        mBinding.viewPager.adapter = ViewPagerAdapter(this)

        TabLayoutMediator(mBinding.tabLayout,mBinding.viewPager) { tab, position ->
            tab.text = "Tab${position}"
        }.attach()
    }
}